<template>
	<view class="myuni-countdown">	
	 {{s}}
	</view>
</template>

<script>
import { mapState } from 'vuex';
	export default {
		props:{
			second:{
			  type:Number,
			  default:60
			}
		},
		data() {
			return {
				time:null,
				s:0
			}
		},
		created() {
			this.s=this.second
			this.countDown()
		},
		computed:{
					...mapState(['themeType'])
				},
		methods: {
			countDown(){
				clearTimeout(this.time)
				this.time=setTimeout(()=>{
					this.s-=1
					if(this.s>0) {this.countDown()}
					else {
						clearTimeout(this.time)
						this.$emit('end')
					}
				},1000)
			}
		}
	}
</script>

<style lang="scss" scoped> 
.myuni-countdown{
	flex: unset !important;
	width: 250rpx;
	height: 72rpx;
	text-align: center;
	line-height: 72rpx;
	font-size: 28rpx;
	background-color: #fff;
	border-radius: 36rpx;
}
</style>
